<?php namespace Org\JiwaNala\Theme;

use Org\JiwaNala\Theme\ThemeDriver;
use Config;
use View;
use URL;
use HTML;

class Theme{
	var $driver;
	
	public function __construct(){
		$driverName = Config::get('theme.driver');
		$this->driver = new ThemeDriver( Config::get('theme.'.$driverName) );
	}
	
	public function driver(){
		return $this->driver;
	}
	
	public function view($view, $domain=NULL, $render=TRUE){
		$resolved = $this->driver()->view($view, $domain);
		return $render? View::make($resolved) : $resolved;
	}
	
	public function style($asset, $domain=NULL, $attr=array()){
		return HTML::style( $this->driver()->style($asset, $domain), $attr );
	}
	
	public function script($asset, $domain=NULL, $attr=array()){
		return HTML::script( $this->driver()->script($asset, $domain), $attr );
	}
	
	public function asset($asset, $domain=NULL){
		return URL::to($this->driver()->asset($asset, $domain));
	}
}